<?php
// +----------------------------------------------------------------------
// | saiadmin [ saiadmin快速开发框架 ]
// +----------------------------------------------------------------------
// | Author: your name
// +----------------------------------------------------------------------
namespace app\cms\model;

use app\cms\model\project_meeting_invitation\ProjectMeetingInvitationSpeaker;
use plugin\saiadmin\app\model\system\SystemUser;
use plugin\saiadmin\basic\BaseModel;

/**
 * 项目会议模型
 */
class ProjectMeeting extends BaseModel
{

    /**
     * 数据表主键
     * @var string
     */
    protected $pk = 'id';

    /**
     * 数据库表名称
     * @var string
     */
    protected $table = 'eb_project_meeting';


    /**
     * 会议名称 搜索
     */
    public function searchMeetingNameAttr($query, $value)
    {
        $query->where('meeting_name', 'like', '%' . $value . '%');
    }


    public function project()
    {
        return $this->belongsTo(Project::class, 'project_id', 'id');
    }

    public function adminUser()
    {
        return $this->hasOne(SystemUser::class, 'id', 'created_by');
    }

    // 一对多 会议邀请讲者
    public function projectMeetingInvitationSpeaker()
    {
        return $this->hasMany(ProjectMeetingInvitationSpeaker::class, 'project_meeting_id', 'id');
    }
}
